package svgedit.gui.actions;

import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.Line2D;
import java.awt.geom.Rectangle2D;

public class ResizeLineHandler extends MouseAdapter{
	
	private int SIZE = 4;
	private Rectangle2D[] points = {
			new Rectangle2D.Double(150, 50, SIZE, SIZE),
			new Rectangle2D.Double(450, 100, SIZE, SIZE) };
	Rectangle2D s = new Rectangle2D.Double();
	Line2D l = new Line2D.Double(10, 10, SIZE, SIZE);

	private int pos = -1;

	public void mousePressed(MouseEvent event) {
		Point p = event.getPoint();

		for (int i = 0; i < points.length; i++) {
			if (points[i].contains(p)) {
				pos = i;
				return;
			}

		}
	}

	public void mouseReleased(MouseEvent event) {
		pos = -1;
	}

	// repaint
	public void mouseDragged(MouseEvent event) {
		if (pos == -1)
			return;

		points[pos].setRect(event.getPoint().x, event.getPoint().y,
				points[pos].getWidth(), points[pos].getHeight());
//		repaint();

	}

}
